package cc.ufinity.networkdiagnose.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import cc.ufinity.networkdiagnose.view.R;

public class SortButtoniListAdapter extends BaseAdapter {

	private Context mContext;
	private List<String> mList;
	
	// ���ز���
	LayoutInflater vi;
	
	public SortButtoniListAdapter(Context context, List<String> list)
	{
		mContext = context;
		mList = list;
	}
	
	@Override
	public int getCount() {
		
		if(mList == null)
			return 0;
		return mList.size();
	}
	
	@Override
	public Object getItem(int position) {
		if(mList == null)
			return null;
		else
			return mList.get(position);
	}
	
	@Override
	public long getItemId(int position) {
		
		return position;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		View view;
		
		if(convertView == null)
		{
			vi = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			view = (LinearLayout) vi.inflate(R.layout.sort_button_list_item, null);
		} else {
			view = convertView;
		}
		
		FillDataIntoView(view,position);
		
		return view;
	}
	
	public void FillDataIntoView(View view, int position) {
		final String name = mList.get(position);
		
		TextView tv = (TextView)view.findViewById(R.id.sort_button_name);

		tv.setText(name);
	}

}
